#ifndef STATEMANAGER_H
#define STATEMANAGER_H

struct ID3D10Device;

struct ID3D10RasterizerState;
struct ID3D10DepthStencilState;
struct ID3D10BlendState;
struct ID3D10SamplerState;

struct D3D10_RASTERIZER_DESC;
struct D3D10_DEPTH_STENCIL_DESC;
struct D3D10_BLEND_DESC;
struct D3D10_SAMPLER_DESC;

using namespace std;

#define MGFX_RS_NO_CULLING "MGFX_RS_NO_CULLING"

#define MGFX_BS_DISABLE_FRAMEBUFFER "MGFX_BS_DISABLE_FRAMEBUFFER"

#define MGFX_DSS_TWO_SIDED_STENCIL "MGFX_DSS_TWO_SIDED_STENCIL"
#define MGFX_DSS_AFTER_SHADOW_VOLUME_STENCIL "MGFX_DSS_AFTER_SHADOW_VOLUME_STENCIL"

#define MGFX_SS_TRILINEAR_WRAP "MGFX_SS_TRILINEAR_WRAP"

namespace mgfx
{

	class StateManager
	{
	public:
		ID3D10RasterizerState * createRasterizerState(const string & key, D3D10_RASTERIZER_DESC * desc);
		ID3D10RasterizerState * getRasterizerState(const string & key);

		ID3D10DepthStencilState * createDepthStencilState(const string & key, D3D10_DEPTH_STENCIL_DESC * desc);
		ID3D10DepthStencilState * getDepthStencilState(const string & key);

		ID3D10BlendState * createBlendState(const string & key, D3D10_BLEND_DESC * desc);
		ID3D10BlendState * getBlendState(const string & key);

		ID3D10SamplerState * createSamplerState(const string & key, D3D10_SAMPLER_DESC * desc);
		ID3D10SamplerState * getSamplerState(const string & key);

		void init(ID3D10Device* device);
		void deinit();

	private:
		ID3D10Device * mDevice;

		typedef map<string, ID3D10RasterizerState*> RSMap;
		RSMap mRasterizerStates;

		typedef map<string, ID3D10DepthStencilState*> DSSMap;
		DSSMap mDepthStencilStates;

		typedef map<string, ID3D10BlendState*> BSMap;
		BSMap mBlendStates;

		typedef map<string, ID3D10SamplerState*> SSMap;
		SSMap mSamplerStates;
	};

}

#endif